package sy.action;

import javax.servlet.http.HttpSession;

import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;

import sy.annotation.MethodName;
import sy.service.InitDataBaseService;

/**
 * 
 * @author 孙宇
 *
 */
@IocBean(name = "initAction")
public class InitAction {

	// 注入initDataBaseService
	@Inject("refer:initDataBaseService")
	private InitDataBaseService initDataBaseService;

	/**
	 * 初始化数据库
	 * 
	 * @param session
	 */
	@At("/global/init")
	@Ok("redirect:/")
	@Aop({ "actionLogInterceptor" })
	@MethodName(name = "初始化数据库")
	public void init(HttpSession session) {
		initDataBaseService.initDataBase();
		if (session != null) {
			session.invalidate();
		}
	}

}
